public class FruitFactory {
    public static Fruit getFruit(String type) {
        switch (type) {
            case "Apple":
                return new Apple();
            case "Orange":
                return new Orange();
            default:
                return null;
        }
    }

    public static void main(String[] args) {
        Fruit fruit = FruitFactory.getFruit("Orange");
        System.out.println(fruit);
    }
}
